echo '解压更新包中...'
cd /tmp
mkdir update
tar xf update.tar.xz -C update
cd /tmp/update/

echo '复制程序中...'
cp -r /tmp/update/work /home/pi/
chmod 777 /home/pi/work -R

echo '复制依赖中...'
cp /tmp/update/bin/flutter-pi /usr/local/bin/flutter-pi
chmod 777 /usr/local/bin/flutter-pi

cp /tmp/update/lib/icudtl.dat /usr/lib/
cp /tmp/update/lib/libflutter_engine.so* /usr/lib/
chmod 777 /usr/lib/libflutter_engine.so*
chmod 777 /usr/lib/icudtl.dat

mkdir -p /data/db/
dpkg -i /tmp/update/debs/* 1>/dev/null 2>/dev/null

cp /tmp/update/etc/rc.local /etc/rc.local
chmod 777 /etc/rc.local

rm /etc/systemd/system/default.target
ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target

cp /tmp/update/gnueabihf/libopencv* /usr/lib/arm-linux-gnueabihf/
chmod 777 /usr/lib/arm-linux-gnueabihf/libopencv*

cd /
rm -rf /tmp/update.tar.xz
rm -rf /tmp/update/

echo '更新软件完成'